package com.cyber4aiagent.tools;

import dev.langchain4j.agent.tool.P;
import dev.langchain4j.agent.tool.Tool;
import dev.langchain4j.agent.tool.ToolMemoryId;
import org.springframework.stereotype.Component;

/**
 * @author Cyber
 * @date 2025/05/11 09:54
 * @description 计算器工具
 */
@Component
public class CalculatorTools {

    /**
     * 加法运算
     */
    @Tool(name = "加法运算", value = "将两个参数a和b相加并返回运算结果")
    public double sum(
            @ToolMemoryId int memoryId,
            @P(value = "a", required = true) double a,
            @P(value = "a", required = true) double b) {
        System.out.println("调用加法运算");
        return a + b;
    }

    /**
     * 求一个数的平方根运算
     */
    @Tool(name = "求一个数的平方根运算", value = "将一个参数a求平方根并返回运算结果")
    public double squareRoot(@ToolMemoryId int memoryId,
                             double a) {
        System.out.println("调用平方根运算");
        return Math.sqrt(a);
    }
}
